home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 027a / dgeclc.zip / CIRCLE.C < prev    next >
Text File  |  1991-05-20  |  2KB  |  92 lines

  1. #include "c:\clipper\include\extend.h"
  2. #include <math.h>
  3.  
  4. typedef int (*PFI)();
  5.  
  6. int     DGEMAINVGA();           /* dGE drivers */
  7. int     DGEMAINCGM();
  8. int     DGEMAINHRC();
  9. int     dgenul();               /* NUL driver */
  10.  
  11. int rval, stlen=0;
  12. char *st=0;
  13.  
  14. PFI dgemgen[] =
  15. {
  16.   DGEMAINHRC,
  17.   DGEMAINCGM,
  18.   dgenul,
  19.   DGEMAINVGA,
  20.   DGEMAINVGA,
  21. };
  22.  
  23. double  dgeatof();
  24.  
  25. int     dgedid = 0;
  26. int     dgeut = -1;
  27.  
  28.  
  29. int dgenul()
  30. { return 6; }
  31.  
  32.  
  33. int boxfill(int a,int b,int c,int d,int e,int f)
  34. {
  35.   return (*dgemgen[dgedid])(st,stlen,0,0,f,e,d,c,b,a, 9);
  36. }
  37.  
  38.  
  39. int dgeinst()
  40.  
  41. {
  42.   int i;
  43.   for(i = 4 ; i >=0 ; i--)  /* dummy call to datareset */
  44.   { rval = (*dgemgen[i])(st,stlen,0,0,0,0,0,0,0,0, 19);
  45.     if(rval != 6) {dgedid = i; dgeut = 0; break; } }
  46.   return (rval);
  47. }
  48.  
  49. /*
  50. *****
  51. * CIRCLE.PRG
  52. *
  53. * Date:         12/02/90
  54. * Written by:   Peter M. Freese
  55. *               Pinnacle Publishing, Inc.
  56. *
  57. * This program demonstrates a circle routine that allows you to draw filled
  58. * circles on top of other screen objects in dGE.  Circles drawn with dGE's
  59. * DRAWCIRCLE() function cannot be filled unless the circle is drawn on a
  60. * blank screen region, since they are filled with the SHADE() function.
  61. * The CIRCLE() routine presented here allows circles to be drawn over other
  62. * image data, and fill somewhat faster than the DRAWCIRCLE() function.
  63. *
  64. * Compile with /c /AL /FPa
  65. *
  66. */
  67.  
  68. CLIPPER circle()
  69. {
  70.   int x,y,r,c;
  71.   int y0 = 1, x0 = 2;
  72.   long r2;
  73.   x = _parni(1);
  74.   y = _parni(2);
  75.   r = _parni(3);
  76.   c = _parni(4);
  77.   if (dgeut) dgeinst();         /* set up dGE drivers */
  78.   r2 = (long)r*r;
  79.   while(y0 < r)
  80.   {
  81.     x0 = (int)sqrt((float)(r2-(long)y0*y0));
  82.     boxfill(x-x0,y-y0,x0+x0,1,128,c);
  83.     boxfill(x-x0,y+y0,x0+x0,1,128,c);
  84.     y0 += 3;
  85.     /* skip virtual rows to save time */
  86.   }
  87. }
  88.  
  89.  
  90.  
  91.  
  92.